Testing some geometry routines in C++
[andmenj-acm.git] / 10327 - Flip sort / 10327.cpp
blob961e9e9ddc9e51999f031eab898be24b6ae034a1
1 /*
2 Problem: 10327 - Flip sort (UVa)
3 Author: Andrés Mejía-Posada
4 (http://blogaritmo.factorcomun.org)
6 */
8 using namespace std;
9 #include <algorithm>
10 #include <iostream>
11 #include <iterator>
12 #include <sstream>
13 #include <fstream>
14 #include <cassert>
15 #include <climits>
16 #include <cstdlib>
17 #include <cstring>
18 #include <string>
19 #include <cstdio>
20 #include <vector>
21 #include <cmath>
22 #include <queue>
23 #include <deque>
24 #include <stack>
25 #include <map>
26 #include <set>
28 #define D(x) cout << #x " is " << x << endl
30 const int N = 1000;
31 int a[N];
33 void randomTestCase(){
34 int n = 1000;
35 printf("%d\n", n);
36 for (int i=0; i<n; ++i){
37 printf("%s%d", i ? " " : "", random() % (1<<10));
39 printf("\n");
40 exit(0);
44 int main(){
45 //randomTestCase();
47 for (int n; scanf("%d", &n) == 1; ){
48 for (int i=0; i<n; ++i){
49 scanf("%d", a+i);
51 int ans = 0;
52 for (int i=0; i<n; ++i){
53 for (int j=i+1; j<n; ++j){
54 ans += a[i] > a[j];
57 printf("Minimum exchange operations : %d\n", ans);
60 return 0;